#!/bin/bash

i=0
j=0
while read line ; do
    state=$(echo $line | awk '{print $6}')
    if [ $state == "LISTEN" ] ; then 
       let i++
    elif [ $state == "ESTABLISHED" ]; then
       let j++
    fi
done  < <(netstat -antp  | sed '1,2d' )

echo  "listen: $i  established: $j"   
